package handingIn;

import java.io.File;
import org.icefaces.component.fileentry.FileEntry;
import org.icefaces.component.fileentry.FileEntryEvent;
import org.icefaces.component.fileentry.FileEntryResults;
import org.icefaces.component.fileentry.FileEntryResults.FileInfo;
import task.ExerciseSheet;


/**
 *
 * @author Thorsten Ludwig
 */
public class HandingInContainer {
    
    private HandingIn handingIn;
    private ExerciseSheet sheet;
    private File file;
    
    public HandingInContainer(HandingIn handingIn, ExerciseSheet sheet, File file) {
        this.handingIn = handingIn;
        this.sheet = sheet;
        this.file = file;
    }

    public void solutionUploadListener(FileEntryEvent event) {
        FileEntry fileEntry = (FileEntry) event.getSource();
        FileEntryResults results = fileEntry.getResults();
        for (FileInfo fileInfo : results.getFiles()) {
            if (fileInfo.isSaved()) {
                this.file = fileInfo.getFile();
            }
        }
    }
    
    public HandingIn getHandingIn() {
        return handingIn;
    }

    public void setHandingIn(HandingIn handingIn) {
        this.handingIn = handingIn;
    }

    public File getFile() {
        return file;
    }

    public ExerciseSheet getSheet() {
        return sheet;
    }
    
    
}
